GETWD
Section: MINTLIB LIBRARY FUNCTIONS
(3)
Updated: 3 March 1993
Index
Return to Main Contents
NAME
getwd, getcwd - get path-name of current working directory
SYNOPSIS
#include <unistd.h>
char *getwd(char *buf);
char *getcwd(char *buf, int size);
DESCRIPTION
getcwd returns a pointer to the current directory path name.
The value of size is the maximum length of the name to be
returned. If buf is a NULL pointer, getcwd will obtain size
bytes of space using malloc. It is up to the calling
process to free this buffer.
getwd is equivalent to getcwd(buf, PATH_MAX). Since PATH_MAX
is the length of the longest path name allowed, this buffer
should always be sufficient. Still, the use of this function
is discouraged, since it is not specified in POSIX and may
therefore be unavailable on other systems.
SEE ALSO
chdir(3),
malloc(3),
Dgetcwd(2),
Dgetdrv(2),
Dgetpath(2)
RETURN VALUES
These functions return NULL is buf is NULL and no memory could
be allocated; otherwise, a pointer to buf is returned.
NOTES
On TOS and MiNT before 0.96, the size parameter to getcwd is only
used for allocating memory; this functions are not yet safe,
i.e. buf may overflow.
On UN*X System V.3, the getcwd function was implemented using
popen() and the pwd command! There had to be a better way...
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- SEE ALSO
-
- RETURN VALUES
-
- NOTES
-
This document was created by
man2html,
using the manual pages.
Time: 11:15:00 GMT, June 22, 2025